1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use arcdps::imgui::Ui;

/// Renders a reset button.
pub fn reset_button(ui: &Ui, label: impl AsRef<str>, confirm: &mut bool) -> bool {
    let mut changed = false;

    if !*confirm {
        if ui.button(label) {
            *confirm = true;
        }
    } else {
        ui.group(|| {
            ui.align_text_to_frame_padding();
            ui.text(format!("{}?", label.as_ref()));

            ui.same_line();
            if ui.button("Confirm") {
                changed = true;
                *confirm = false;
            }

            ui.same_line_with_spacing(0.0, 5.0);
            if ui.button("Cancel") {
                *confirm = false;
            }
        });
    }

    changed
}